<?php

namespace Trawind\Remotes\Repositories\Account\Config;

use Illuminate\Support\Facades\Redis;
use Trawind\Basics\Enums\ServiceDomain;
use Trawind\Remotes\BaseRepository;
use Trawind\Helpers\UserHelper;
use Trawind\Remotes\Contracts\Repositories\Account\Config\CommonRepository;

/**
 * Class CommonRepositoryEloquent.
 * @package namespace TrawindCloud\Repositories\Eloquent;
 */
class CommonRepositoryEloquent extends BaseRepository implements CommonRepository
{

    public $baseRoute='/config/commons';

    /**
     * UserRepositoryEloquent constructor.
     */
    public function __construct()
    {
        $this->domain = ServiceDomain::ACCOUNT_DOMAIN();
    }

    public function getData(string $service, string $module = '')
    {
        $search = '';
        $service and $search .= "service:$service";
        $module and $search .= ";module:$module";
        return $this->getListBySearch(['search' => $search, 'searchJoin' => 'and']);
    }


    public function saveConfig(array $configs)
    {
        return $this->setUrl($this->baseRoute)
            ->setClientOptions(['form_params' => ['data' => $configs]])
            ->result('POST');
    }

    public function all($columns = ['*'])
    {
        return $this->setUrl($this->baseRoute)->result();
    }

    public function find($id, $columns = ['*'])
    {
        // TODO: Implement find() method.
    }

    public function create(array $attributes)
    {
        // TODO: Implement create() method.
    }

    public function update(array $attributes, $id)
    {
        // TODO: Implement update() method.
    }
}
